<template>
    <view>
        <!-- #ifdef MP-KUAISHOU -->
        <ksPageWatch ref="ksBox" />
        <!-- #endif -->
        <!-- #ifdef MP-TOUTIAO -->
        <TtPageWatch ref="ttBox" />
        <insertAdTt ref="insertAdTt" />
        <!-- #endif -->
    </view>
</template>

<script>
import ksPageWatch from './ks_page.vue'
import TtPageWatch from './tt_page.vue'
import insertAdTt from '../video/components/insertAdTt.vue';
export default {
    components: {
        ksPageWatch,
        TtPageWatch,
        insertAdTt
    },
    data() {
        return {
        }
    },
    async onShow() {
        // 切换刷新
        //#ifdef MP-KUAISHOU
        await this.$nextTick()
        setTimeout(() => {
            this.$refs.ksBox && this.$refs.ksBox.reset()
        }, 100)

        //#endif
        //#ifdef MP-TOUTIAO
        await this.$nextTick()
        setTimeout(() => {
            this.$refs.ttBox && this.$refs.ttBox.reset()
        }, 100)
        const currentTimestamp = Math.floor(Date.now() / 1000);
        if (currentTimestamp - getApp().globalData.lastAdTimestamp > 180 && !getApp().globalData.isAdComeCheck) {
            // 曝光插屏广告
            console.log('Show interstitial ad');
            setTimeout(() => {
                this.$refs.insertAdTt && this.$refs.insertAdTt.isShowAd()
            }, 200)
            console.log(this.$refs.insertAdTt,'this.$refs.insertAdTt-------');
            // getApp().globalData.lastAdTimestamp = currentTimestamp;
        } else {
            console.log('Skip interstitial ad');
        }
        //#endif
    },
    onShareAppMessage: function () {
        var shareJson = {
            path: '/pages/bg_watch/bg_watch',
            data: {
                page: 'mine',
                sharePosition: '/pages/bg_watch/bg_watch',
                from: '/position/share/share',
                sharePage: '/pages/bg_watch/bg_watch'
            }
        };
        // 达人分享批次
        console.log(getApp().globalData.shareBatchId)
        if (getApp().globalData.shareBatchId) {
            shareJson.channel = 'video'
            shareJson.extra = {
                hashtag_list: ['精彩短剧热播中👈']
            }
        }
        shareJson.title = '精彩短剧热播中👈';
        return this.formatShare(shareJson);
    }
};
</script>

